﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Hangjing.Common;
using Hangjing.SQLServerDAL;
using Hangjing.Model;

public partial class Admin_shop_DistancePayDetail : System.Web.UI.Page
{
    shopdelivery dal = new shopdelivery();
    Points dal_togo = new Points();

    protected void Page_Load(object sender, EventArgs e)
    {
        ValidatorSet validator = new ValidatorSet("Admin");
        validator.SetValidator();

        if (!IsPostBack)
        {
            //编辑
            int TogoId = HjNetHelper.GetQueryInt("tid", 0);//商家id

            hidTogoId.Value = TogoId.ToString();

            BindFoodSortData(TogoId);

            pageType.Text = "修改规则";

        }
    }

    protected void btSave_Click(object sender, EventArgs e)
    {
        Hangjing.Model.shopdeliveryInfo model = new shopdeliveryInfo();
        model.tid = Convert.ToInt32(Request.QueryString["tid"]);
        model.distancestart = Convert.ToDecimal(WebUtility.InputText(this.tbdistancestart.Text));
        model.distanceend = Convert.ToDecimal(WebUtility.InputText(this.tbdistanceend.Text));
        model.minmoney = 0;
        model.sendmoney = Convert.ToDecimal(WebUtility.InputText(this.tbsendmoney.Text));
        model.ReveVar2 = "";
        model.ReveVar1 = "";
        model.ReveInt2 = 0;
        model.ReveInt1 = Convert.ToDecimal(tbReveInt1.Text);
        model.ReveFloat1 = Convert.ToDecimal(WebUtility.InputText(this.tbReveFloat1.Text));
        model.ReveFloat2 = 0;
       
        model.AddTime = DateTime.Now;


        //判断权限
        int _rs = WebUtility.checkOperator(2);
        if (_rs == 0)
        {
            AlertScript.RegScript(this.Page, this.UpdatePanel1, "alert('无操作权限','success','true',5);init();");
            return;
        }
        dal.Add(model);

        AlertScript.RegScript(this.Page, UpdatePanel1, "tipsWindown('操作成功','id:divShowContent','640','150','true','','true','text')");



    }

    protected void BindFoodSortData(int TogoId)
    {
        PointsInfo togomodel = dal_togo.GetModel(TogoId);

        if (togomodel != null)
        {
            this.lbtogoname.InnerText = togomodel.Name;
        }


        shopdeliveryInfo model = dal.GetModelByShopID(TogoId);
        if (model != null)
        {
            this.tbdistancestart.Text = model.distancestart.ToString("0");
            this.tbdistanceend.Text =model.distanceend.ToString("0");
            this.tbReveFloat1.Text = model.ReveFloat1.ToString();
            this.tbsendmoney.Text = model.sendmoney.ToString();
            tbReveInt1.Text = model.ReveInt1.ToString();
            lbbasedistance.InnerText = model.distancestart.ToString("0");
        }


    }
}